<?php

namespace App\ModelFilters;

use EloquentFilter\ModelFilter;

class QuestionReportFilter extends ModelFilter
{
    /**
    * Related Models that have ModelFilters as well as the method on the ModelFilter
    * As [relationMethod => [input_key1, input_key2]].
    *
    * @var array
    */
    public $relations = [];


    public function nickname($value) {
        return $this->whereHas('user', function ($query) use ($value) {
            return $query->where('user.nickname', 'like',  '%'.$value.'%');
        });
    }

    public function type($value) {
        return $this->whereIn('type', explode(',', $value));
    }

    public function show($value) {
        return $this->where('show', $value);
    }
}
